t = int(input())
for i in range(t):
n, m = map(int, input().split())
s = []
for j in range(n):
s.append(input())
minx = 10 ** 9
miny = 10 ** 9
for x in range(n):
for y in range(m):
if s[x][y] == 'R':
minx = min(minx, x)
miny = min(miny, y)
print('YES' if s[minx][miny] == 'R' else 'NO')
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll MOD=1000000007;
// vector<ll> seive(ll n){ //vector of primes in [1,n]
// vector <ll> isPrime(n+1,1);
// vector <ll> temp;
// isPrime[0]=isPrime[1]=0;
// for(ll i=2;i<n+1;i++){
// if(isPrime[i]){
// for(ll j=i*i;j<n+1;j+=i){
// isPrime[j]=0;
// }
// }
// }
// for(ll i=0;i<n+1;i++){
// if(isPrime[i]) temp.push_back(i);
// }
// return temp;
// }
// ll power(ll a,ll b){
// ll ans=1;
// while(b){
// if(b&1) ans*=a;
// a=a*a;
// b=b>>1;
// }
// return ans;
// }
void solve(){
ll n,m;
cin >> n >> m;
char a[n][m];
ll mx=INT_MAX,my=INT_MAX;
ll rf=0;
for(ll i=0;i<n;i++){
for(ll j=0;j<m;j++){
cin >> a[i][j];
if(a[i][j]=='R'){
rf=1;
mx=min(mx,i);
my=min(my,j);
}
}
}
if(rf==0) {cout << "NO" << endl; return;}
if(a[mx][my]=='R') cout << "YES" << endl;
else cout << "NO" << endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// solve();
ll t; cin >> t;
while(t--){
solve();
}
}
20. Valid Parentheses | 746. Min Cost Climbing Stairs |
392. Is Subsequence | 70. Climbing Stairs |
53. Maximum Subarray | 1527A. And Then There Were K |
1689. Partitioning Into Minimum Number Of Deci-Binary Numbers | 318. Maximum Product of Word Lengths |
448. Find All Numbers Disappeared in an Array | 1155. Number of Dice Rolls With Target Sum |
415. Add Strings | 22. Generate Parentheses |
13. Roman to Integer | 2. Add Two Numbers |
515. Find Largest Value in Each Tree Row | 345. Reverse Vowels of a String |
628. Maximum Product of Three Numbers | 1526A - Mean Inequality |
1526B - I Hate 1111 | 1881. Maximum Value after Insertion |
237. Delete Node in a Linked List | 27. Remove Element |
39. Combination Sum | 378. Kth Smallest Element in a Sorted Matrix |
162. Find Peak Element | 1529A - Eshag Loves Big Arrays |
19. Remove Nth Node From End of List | 925. Long Pressed Name |
1051. Height Checker | 695. Max Area of Island |